package ntu.metaweb.result;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@XStreamAlias("comment")
public class Comment {
	
	public int rating;
	@XStreamAlias("username")
	public String commenter;
	public String timestamp;
	public String text;
	@XStreamAsAttribute
	public String id;
	@XStreamAlias("parentid")
	@XStreamAsAttribute
	public String parentId;
	
	public Comment(ntu.metaweb.storage.Comment comment) {
		this.rating = comment.getTotalRating();
		this.commenter = comment.getContributors().iterator().next();
		this.timestamp = comment.getTimestamp().toString();
		this.text = comment.getText();
		if (comment.getParentId() != -1) {
			this.parentId = "comment_" + comment.getParentId();
		}
		this.id = "comment_" + comment.getId();
	}
}
